package org.atguigu.spring6.autowired.service;

import org.atguigu.spring6.autowired.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    //注入dao
    //第一种方式 属性注入
//    @Autowired
//    private UserDao userDao;

    //第二种方式 set方法注入
//    private UserDao userDao;
//    @Autowired
//    public void setUserDao(UserDao userDao)
//    {
//        this.userDao = userDao;
//    }
    //第三种方式构造方法注入
//    private UserDao userDao;
//    @Autowired
//    private UserServiceImpl(UserDao userDao){
//        this.userDao = userDao;
//    }

    //最后方式：两个注解，根据名称注入
    @Autowired
    @Qualifier("userRedisDaoImpl")
    private UserDao userDao;


    public void add()
    {
        System.out.println("service add....");
        userDao.add();
    }

}
